<?php

use yii\db\Migration;

class m240417_014729_diandi_mall_account_member extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%diandi_mall_account_member}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT",
            'bloc_id' => "int(11) NULL COMMENT '公司ID'",
            'store_id' => "int(11) NULL COMMENT '商户ID'",
            'member_id' => "int(11) NULL COMMENT '会员ID'",
            'self_money' => "decimal(11,2) NOT NULL COMMENT '个人奖金'",
            'self_withdraw' => "decimal(11,2) NOT NULL COMMENT '个人已提现'",
            'self_freeze' => "decimal(11,2) NOT NULL COMMENT '个人冻结'",
            'team_money' => "decimal(11,2) NOT NULL COMMENT '团队奖金'",
            'team_withdraw' => "decimal(11,2) NOT NULL COMMENT '团队奖金提现'",
            'team_freeze' => "decimal(11,2) NOT NULL COMMENT '团队奖金冻结'",
            'store_money' => "decimal(11,2) NOT NULL COMMENT '店铺收益'",
            'store_withdraw' => "decimal(11,2) NOT NULL COMMENT '店铺可提现'",
            'store_freeze' => "decimal(11,2) NOT NULL COMMENT '店铺收益冻结'",
            'agent_money' => "decimal(11,2) NOT NULL COMMENT '代理收益'",
            'agent_withdraw' => "decimal(11,2) NOT NULL COMMENT '代理可提现'",
            'agent_freeze' => "decimal(11,2) NOT NULL COMMENT '代理奖金冻结'",
            'water_money' => "decimal(11,2) NULL",
            'water_withdraw' => "decimal(11,2) NULL",
            'water_freeze' => "decimal(11,2) NULL",
            'create_time' => "int(11) NULL COMMENT '注册时间'",
            'update_time' => "int(11) NULL COMMENT '更新时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT");
        
        /* 索引设置 */
        $this->createIndex('member_id','{{%diandi_mall_account_member}}','member_id',0);
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%diandi_mall_account_member}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

